import time

from django.http import HttpResponse
from django.views.decorators.cache import cache_page
from django.core.cache import cache


# 视图缓存，把整个return结果缓存
@cache_page(10)
def test_cache(request):
    t = time.time()
    return HttpResponse('t is {}'.format(t))


def test_cache2(request):
    t = time.time()
    return HttpResponse('t2 is {}'.format(t))


def test_cache3(request):
    t = time.time()
    return HttpResponse('t2 is {}'.format(cache.get_or_set('test_cache', t, timeout=10)))


def test_mw(request):
    print('--my view do--')
    sss
    return HttpResponse('this is my view')
